<?php
declare (strict_types = 1);

namespace app\admin\controller;
use think\facade\Cache;
class Index
{
    public function index()
    {
       $test = new \app\common\Test;
       echo $test->hello('thinkphp');
    }

    public function setredis()
    {
        $cacheKey = 'user_info';
        $userInfo = Cache::get($cacheKey);
        if (!$userInfo) {
            $userInfo = 1;
            Cache::set($cacheKey, $userInfo, 3600);
        }

    }

    public function getredis()
    {
        $cacheKey = 'user_info';
        $userInfo = Cache::get($cacheKey);
        if (!$userInfo) {
            return '没有数据';
        }
        return json($userInfo);
    }
}
